home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / dev / gui / FoxGuiSource.lha / FoxLibSource / GuiSys.h < prev    next >
C/C++ Source or Header  |  2001-07-08  |  11KB  |  320 lines

  1. /* FoxGUI - The fast, flexible, free Amiga GUI system
  2.     Copyright (C) 2001 Simon Fox (Foxysoft)
  3.  
  4. This library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  5. Foxysoft: www.foxysoft.co.uk      Email:simon@foxysoft.co.uk                */
  6.  
  7.  
  8. #define INTUI_V36_NAMES_ONLY
  9.  
  10. #include <intuition/intuitionbase.h>
  11. #include <graphics/gfxbase.h>
  12. #include <exec/memory.h>
  13. #include <proto/iffparse.h>
  14.  
  15. #define A500     33
  16. #define A3000    36
  17. #define A500PLUS 37
  18. #define A1200    39
  19.  
  20. #define ENTER    TRUE
  21. #define EXIT     FALSE
  22.  
  23. #define GUI_WARNING (short) 0
  24. #define GUI_ERROR   (short) 1
  25.  
  26. #define MAX_EDIT_BOX_LEN            256
  27. #define DD_LIST_BOX_BUTTON_WIDTH    17
  28.  
  29. #define SCROLL_BUTTON_WIDTH    16  // It would be nice for this to be narrower but this is the smallest width that will display correctly on an old A500
  30. #define SCROLL_BUTTON_HEIGHT    10
  31.  
  32. // Prototypes for functions that should be available gui wide but not to the end user...
  33. char *GetFName(void);
  34. char *GetPath(void);
  35. void WinMsgLoop(GuiWindow *ModalWin);
  36. PushButton *MakeFileButton(GuiWindow *Wptr, char *name, int left, int top, int width, int height, int key, struct Border *cb, int (*callfn) (char*, char*));
  37. ListBox *CreateListBox(void *Parent, int left, int top, int width, int height, int lborder,
  38.         int tborder, int frontpen, struct TextAttr *font, int __far __stdargs (*Eventfn) (ListBox*, short, int, void**),
  39.         int flags, char *objecttype);
  40. GuiWindow *CreateGuiWindow(GuiScreen *pgs, struct Screen *Scr, int Left, int Top, int Width, int Height, int Dpen, int Bpen, char *Title, int flags, int (* __far __stdargs eventfn)(struct GWS*, int, int, int, void*));
  41. void SleepFile(void);
  42. void WakeFile(void);
  43. void ListBoxScrollUp(ListBox *nlb, BOOL refreshscroller);
  44. void ListBoxScrollDown(ListBox *nlb, BOOL refreshscroller);
  45. ListBoxItem* FOXLIB ItemElem(REGA1 ListBox *lb, REGA2 int target);
  46. int ItemNum(ListBox *lb, ListBoxItem *target);
  47. void ListBoxRehilight(ListBox *lb, int HiNum, ListBoxItem *HiElem, BOOL unhilight,
  48.         BOOL hilight);
  49. ListBoxItem *GetTopElem(ListBox *lb, int *topnum);
  50. ListBoxItem *NextItem(ListBoxItem *Item);
  51. int ListBoxItemFromXY(ListBox *lb, long x, long y, ListBoxItem **Item, int *ItemNum);
  52. void ResizeButton(PushButton *Bptr, int x, int y, int width, int height, BOOL eraseold);
  53. void ResizeEditBox(EditBox *eb, int x, int y, int len, BOOL eraseold);
  54. void ResizeOutputBox(OutputBox *ob, int x, int y, int len, BOOL eraseold);
  55. void ResizeRadioButton(RadioButton *rb, int x, int y, int width, int height, BOOL eraseold);
  56. void ResizeTickBox(TickBox *tb, int x, int y, int width, int height, BOOL eraseold);
  57. void ResizeProgressBar(ProgressBar *pb, int x, int y, int width, int height, BOOL eraseold);
  58. void ResizeFrame(Frame *frame, int x, int y, int width, int height, BOOL eraseold);
  59. void ResizeListBox(ListBox *lb, int x, int y, int width, int height, double xfactor, double yfactor, BOOL eraseold);
  60. BOOL SetListBoxTabStops(ListBox *nlb, BOOL refresh, short num, ...);
  61. void DrawRBCentre(RadioButton *rb);
  62. BOOL HideProgressBar(ProgressBar *pb);
  63. BOOL ShowProgressBar(ProgressBar *pb);
  64. BOOL ShowFrame(Frame *Fptr);
  65. BOOL HideFrame(Frame *Fptr);
  66. BOOL HideListBox(ListBox *lb);
  67. BOOL ShowListBox(ListBox *lb);
  68. BOOL ShowDDListBox(DDListBox *p);
  69. BOOL HideDDListBox(DDListBox *p);
  70. BOOL ShowEditBox(EditBox *p);
  71. BOOL HideEditBox(EditBox *p);
  72. BOOL ShowButton(PushButton *Bptr);
  73. BOOL HideButton(PushButton *Bptr);
  74. BOOL HideOutputBox(OutputBox *p);
  75. BOOL ShowOutputBox(OutputBox *p);
  76. BOOL HideTickBox(TickBox *tb);
  77. BOOL ShowTickBox(TickBox *tb);
  78. BOOL HideRadioButton(RadioButton *rb);
  79. BOOL ShowRadioButton(RadioButton *rb);
  80. BOOL HideTabControl(TabControl *tc);
  81. BOOL ShowTabControl(TabControl *tc);
  82. void GuiSetLastErrAndLine(char *error, char *file, int line);
  83. void DestroyButton(PushButton *Bptr, BOOL refresh);
  84. void DestroyAllButtons(BOOL refresh);
  85. void DestroyWinButtons(GuiWindow *w, BOOL refresh);
  86. void DestroyTabControl(TabControl *tc, BOOL refresh);
  87. void DestroyWinTabControls(GuiWindow *win, BOOL refresh);
  88. void DestroyAllTabControls(BOOL refresh);
  89. void DestroyFrame(Frame *Fptr, BOOL refresh);
  90. void DestroyAllFrames(BOOL refresh);
  91. void DestroyWinFrames(GuiWindow *w, BOOL refresh);
  92. void DestroyRadioButton(RadioButton *rb, BOOL refresh);
  93. void DestroyAllRadioButtons(BOOL refresh);
  94. void DestroyWinRadioButtons(GuiWindow *gw, BOOL refresh);
  95. void DestroyWinTickBoxes(GuiWindow *gw, BOOL refresh);
  96. void DestroyAllTickBoxes(BOOL refresh);
  97. void DestroyTickBox(TickBox *tb, BOOL refresh);
  98. void DestroyDDListBox(DDListBox *p, BOOL refresh);
  99. void DestroyAllDDListBoxes(BOOL refresh);
  100. void DestroyWinDDListBoxes(GuiWindow *c, BOOL refresh);
  101. void DestroyEditBox(EditBox *p, BOOL refresh);
  102. void DestroyAllEditBoxes(BOOL refresh);
  103. void DestroyWinEditBoxes(GuiWindow *c, BOOL refresh);
  104. void DestroyOutputBox(OutputBox *p, BOOL refresh);
  105. void DestroyAllOutputBoxes(BOOL refresh);
  106. void DestroyWinOutputBoxes(GuiWindow *c, BOOL refresh);
  107. BOOL DestroyListBox(ListBox *lb, BOOL refresh);
  108. void DestroyAllListBoxes(BOOL refresh);
  109. void DestroyWinListBoxes(GuiWindow *w, BOOL refresh);
  110. void DestroyProgressBar(ProgressBar *pb, BOOL refresh);
  111. BOOL DestroyTimer(Timer *t);
  112. void DestroyAllTimers(void);
  113. void EnableRadioButton(RadioButton *rb);
  114. void DisableRadioButton(RadioButton *rb);
  115. void EnableTickBox(TickBox *tb);
  116. void DisableTickBox(TickBox *tb);
  117. void DisableButton(PushButton *Bptr);
  118. void DisableAllButtons(void);
  119. void DisableWinButtons(GuiWindow *w);
  120. void EnableButton(PushButton *Bptr);
  121. void EnableAllButtons(void);
  122. void EnableWinButtons(GuiWindow *w);
  123. void DisableFrame(Frame *Fptr);
  124. void DisableAllFrames(void);
  125. void DisableWinFrames(GuiWindow *w);
  126. void EnableFrame(Frame *Fptr);
  127. void EnableAllFrames(void);
  128. void EnableWinFrames(GuiWindow *w);
  129. void DisableTabControl(TabControl *tc);
  130. void EnableTabControl(TabControl *tc);
  131. void DisableAllDDListBoxes(BOOL redraw);
  132. void DisableWinDDListBoxes(GuiWindow *c, BOOL redraw);
  133. void DisableEditBox(EditBox *p, BOOL redraw);
  134. void DisableDDListBox(DDListBox *p, BOOL redraw);
  135. void DisableAllEditBoxes(BOOL redraw);
  136. void DisableWinEditBoxes(GuiWindow *c, BOOL redraw);
  137. void EnableEditBox(EditBox *p, BOOL redraw);
  138. void EnableDDListBox(DDListBox *p, BOOL redraw);
  139. void EnableAllEditBoxes(BOOL redraw);
  140. void EnableWinEditBoxes(GuiWindow *c, BOOL redraw);
  141. void EnableAllDDListBoxes(BOOL redraw);
  142. void EnableWinDDListBoxes(GuiWindow *c, BOOL redraw);
  143. BOOL DisableListBox(ListBox *lb);
  144. void DisableAllListBoxes(void);
  145. void DisableWinListBoxes(GuiWindow *w);
  146. BOOL EnableListBox(ListBox *lb);
  147. void EnableAllListBoxes(void);
  148. void EnableWinListBoxes(GuiWindow *w);
  149. void CloseGuiWindow(GuiWindow *w);
  150. void CloseAllWindows(void);
  151. void CloseScrWindows(GuiScreen *sc);
  152.  
  153. #define NumLines(n)    ((((n)->WidgetData->height - ((n)->LR ? SCROLL_BUTTON_HEIGHT : 0) - ((n)->NoTitles ? 5 : 2) - (((n)->NoTitles ? 4 : 2) * (n)->TBorder)) / (n)->Font->ta_YSize) - (n)->NoTitles)
  154. #define ISGUIWINDOW(w)    (((GuiWindow *) w)->WidgetData->ObjectType == WindowObject)
  155. #define ISGUISCREEN(s)    (((GuiScreen *) s)->WidgetData->ObjectType == ScreenObject)
  156. #define SetLastErrAndLine(a,b)  GuiSetLastErrAndLine(a,__FILE__,b)
  157. #define SetLastErr(a)           GuiSetLastErrAndLine(a,__FILE__,__LINE__)
  158.  
  159. //    Structure for storing a list of user-defined gadgets
  160. typedef struct UGad
  161.     {
  162.     struct Gadget *gad;
  163.     GuiWindow *win;
  164.     struct UGad *next;
  165.     int (*fn)(struct Gadget*, struct IntuiMessage *);
  166.     } UserGadget;
  167.  
  168. struct GuiStruct
  169.    {
  170.     struct Process        *Proc; // A pointer to this Exec process
  171.     GuiScreen            *FirstScr;
  172.    OutputBox         *FirstOutputBox;
  173.     EditBox                *FirstEditBox;
  174.     ListBox                *FirstListBox;
  175.     TickBox                *FirstTickBox;
  176.     RadioButton            *FirstRadioButton;
  177.     Frame                    *FirstFrame;
  178.    PushButton        *GGLfirst;
  179.     GuiWindow            *GWLfirst;
  180.     Timer                    *FirstTimer;
  181.     ProgressBar            *FirstProgressBar;
  182.     TabControl            *FirstTabControl;
  183.     UserGadget            *FirstUserGadget;
  184.    struct IntuiText  Message1, Message2, Message3;
  185.    struct NewWindow  MessageNWin;
  186.    struct Window     *MessageWin;
  187.    short             LibVersion;
  188.    BOOL              CleanupFlag, DroppingList, Done, MessageDisplayed, ListFocusOnly;
  189.    int               ARperiod, ARdelay, DDListX, DDListY;
  190.     unsigned long     NumAllocs;
  191.    FILE              *DebugFile;
  192.    UBYTE             ibuf;
  193.    unsigned long     consig, winsig, scrsig;
  194.     short                    HiPen, LoPen;
  195.     ULONG                    WBMode;
  196.     UWORD                    WBDepth;
  197.     UWORD                    WBPen[NUM_WB_PENS + 1];
  198.     int                    BorderCol, BackCol, TextCol;
  199.    };
  200.  
  201. // Typedefs for functions returning an integer
  202. typedef int __far __stdargs (*IntFnPtr)();
  203. typedef int __far __stdargs (*LBIntFnPtr) (ListBox*,short,int,void **);
  204. typedef int __far __stdargs (*TCIntFnPtr) (TreeControl*,short,TreeItem*,void **);
  205.  
  206.  
  207. #ifdef FOXGUI
  208.     #define EXT
  209. #else
  210.     #define EXT extern
  211. #endif
  212.  
  213. EXT void        GuiReportError(char*, short);
  214. EXT float    GetFloatFromStr(char*);
  215. EXT void        QueueAllMessages(void);
  216. EXT void        AbortAllMessages(void);
  217.  
  218. EXT struct IntuitionBase *IntuitionBase;
  219. EXT struct GfxBase       *GfxBase;
  220. EXT struct Library       *LayersBase;
  221. EXT struct GuiStruct     Gui;
  222. EXT char ListBoxKeyPress;
  223. EXT BOOL FastMallocs;
  224.  
  225. EXT struct TextAttr GuiFont, GuiULFont;
  226.  
  227. EXT char *FrameObject
  228. #ifdef FOXGUI
  229.     = "Frame"
  230. #endif
  231.     ;
  232.  
  233. EXT char *ButtonObject
  234. #ifdef FOXGUI
  235.     = "Button"
  236. #endif
  237.     ;
  238.  
  239. EXT char *TabControlObject
  240. #ifdef FOXGUI
  241.     = "TabControl"
  242. #endif
  243.     ;
  244.  
  245. EXT char *ListBoxObject
  246. #ifdef FOXGUI
  247.     = "ListBox"
  248. #endif
  249.     ;
  250.  
  251. EXT char *TreeControlObjectType
  252. #ifdef FOXGUI
  253.     = "TreeControl"
  254. #endif
  255.     ;
  256.  
  257. EXT char *DDListBoxObject
  258. #ifdef FOXGUI
  259.     = "DDListBox"
  260. #endif
  261.     ;
  262.  
  263. EXT char *EditBoxObject
  264. #ifdef FOXGUI
  265.     = "EditBox"
  266. #endif
  267.     ;
  268.  
  269. EXT char *OutputBoxObject
  270. #ifdef FOXGUI
  271.     = "OutputBox"
  272. #endif
  273.     ;
  274.  
  275. EXT char *ProgressBarObject
  276. #ifdef FOXGUI
  277.     = "ProgressBar"
  278. #endif
  279.     ;
  280.  
  281. EXT char *TickBoxObject
  282. #ifdef FOXGUI
  283.     = "TickBox"
  284. #endif
  285.     ;
  286.  
  287. EXT char *RadioButtonObject
  288. #ifdef FOXGUI
  289.     = "RadioButton"
  290. #endif
  291.     ;
  292.  
  293. EXT char *WindowObject
  294. #ifdef FOXGUI
  295.     = "Window"
  296. #endif
  297.     ;
  298.  
  299. EXT char *ScreenObject
  300. #ifdef FOXGUI
  301.     = "Screen"
  302. #endif
  303.     ;
  304.  
  305. EXT char *TimerObject
  306. #ifdef FOXGUI
  307.     = "Timer"
  308. #endif
  309.     ;
  310.  
  311. #ifdef __STORM__
  312.     #define ListBoxLeftEdge(a,b)    (int)((a)->LBorder+2+(b))
  313. #else
  314.     // Returns the LeftEdge of an item which has a tabstop of tabx
  315.     static __inline int ListBoxLeftEdge(ListBox *lb, int tabx)
  316.         {
  317.             return lb->LBorder + 2 + tabx;
  318.         }
  319. #endif
  320.